<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>宠爱吖</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-col-lg-offset3 layui-col-lg6">
        <form class="layui-form" action="">
            <div class="layui-input-inline">
                <div class="layui-form-item">
                    <label class="layui-form-label">序号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="id" id="id" autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-form-item">
                    <label class="layui-form-label">宠物名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" id="name" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">套餐选择：</label>
                <div class="layui-input-block" >
                    <select name="setMeal" id="setMeal">
                        <option value="0"></option>
                        <option value="1">简单套餐</option>
                        <option value="2">豪华套餐</option>
                        <option value="3">运动套餐</option>
                        <option value="4">医疗套餐</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">宠物状态：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="state"
                               id="state" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
<!--            <div class="layui-form-item">-->
<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">创建日期：</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" name="time"-->
<!--                               id="time"  autocomplete="off" lay-verify="date"-->
<!--                               class="layui-input">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">修改套餐</button>
                </div>
            </div>
        </form>
    </div>
</div>
</div>
<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','laydate'], function() {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.$;
        var str = localStorage.getItem("diet");
        var s = JSON.parse(str);
        $("#id").val(s.id);
        $("#name").val(s.name);
        $("#setMeal").val(s.setMeal);
        $("#state").val(s.state);

        laydate.render({
            elem: '#time'
        });
        //监听提交
        form.on('submit(demo1)', function(data) {
            //请求添加接口
            $.post("/api/diet/update.do", data.field, function(res) {
                if (res.code == 10000) {
                    //修改成功
                    location.href = "listdiet.html";
                } else {
                    //添加失败
                    layer.alert("修改失败", {
                        title: '亲，修改失败，请检查网络'
                    })
                }
            })
            return false;
        });
    });
</script>
</body>
</html>
